$("#joinTime").datepicker({
    format: 'yyyy-mm-dd'
});

//查询 基本 数据
$CertusJsonAjax.ajax("baseUserByProcessId",{
    "processInstanceId": $CertusJsonAjax.getProInstanceId(),
    "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
},function(res){

    if(res.data){
        $$scope.rzlcStepEntity = res.data;

        $$scope.rzlcStepEntity.baseUser.departmentUser.companyName = $$scope.getBelongCompanyName($$scope.rzlcStepEntity.baseUser.belongCompanyCode);


        $$scope.rzlcStepEntity.stepInstanceId = $CertusJsonAjax.getStepInstanceId();
        $$scope.rzlcStepEntity.processInstanceId = $CertusJsonAjax.getProInstanceId();

        $$scope.companySelect = [
            {name:"赛特斯集团",code:"STSJT"},
            {name:"赛特斯广东",code:"STSGD"},
            {name:"赛特斯南京",code:"STSNJ"},
            {name:"赛特斯北京",code:"STSBJ"},
            {name:"赛特斯上海",code:"STSSH"},
            {name:"融合运维事业部",code:"SYB-RX"},
            {name:"浩方科技",code:"HFKJ"},
            {name:"浩方信息",code:"HFXX"}
        ]

        for(var cs in $$scope.companySelect){
            if($$scope.companySelect[cs].code == $$scope.rzlcStepEntity.baseUser.belongCompanyCode){
                $$scope.rzlcStepEntity.baseUser.departmentUser.companyName = $$scope.companySelect[cs].name;
            }
        }
    }
})

$$scope.getSex = function(a){
    if(a == 1){
        return "男";
    }else{
        return "女";
    }
}

$$scope.getMarriage = function(a){
    if(a == 1){
        return "已婚";
    }else if(a == 0 ){
        return "未婚";
    }else if(a == 2){
        return "已婚已育";
    }

    return "未婚";
}

$$scope.getBelongCompanyName = function(companyCode){
    if(companyCode == "STSJT"){
        return "赛特斯集团";
    }else if(companyCode == "STSGD"){
        return "赛特斯广东";
    }else if(companyCode == "HFKJ"){
        return "浩方科技";
    }else if(companyCode == "HFXX"){
        return "浩方信息";
    }else if(companyCode == "STSBJ"){
        return "赛特斯北京";
    }else if(companyCode == "STSNJ"){
        return "赛特斯南京";
    }
}

$CertusJsonAjax.ajax("queryYGRZProcessTrace",{
    "processInstanceId": $CertusJsonAjax.getProInstanceId(),
    "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
},function(res){
    $$scope.processCCBXTrace = res.data;
})

$$scope.belongCompanyCodeSelect = [
    {name:"赛特斯广东",code:"STSGD"},
    {name:"赛特斯南京",code:"STSNJ"},
    {name:"赛特斯北京",code:"STSBJ"},
    {name:"赛特斯上海",code:"STSSH"},
    {name:"融合运维事业部",code:"SYB-RX"},
    {name:"浩方科技",code:"HFKJ"},
    {name:"浩方信息",code:"HFXX"}
]

//不同意 员工入职
$$scope.cancelEntry = function(){
    layer.confirm('确认取消入职流程？', {
        title: '提示信息',
        btn: ["确定", '取消'] //按钮
    }, function () {
        $CertusJsonAjax.ajax("cancelEntry",{
            "processInstanceId": $CertusJsonAjax.getProInstanceId(),
            "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
        },function(res){
            if(res.data == "success"){
                history.back();
                layer.closeAll();
                return;
            }

        })
    });

}

//退回至 员工 入职 起草人
$$scope.sendBackEntry = function(){
    $CertusJsonAjax.ajax("sendBackEntry",{
        "processInstanceId": $CertusJsonAjax.getProInstanceId(),
        "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
    },function(res){
        if(res.data == "success"){
            history.back();
            return;
        }
        layer.msg("程序出错");
    })
}

//同意 提交
$$scope.confirmEntry = function(){
    $CertusJsonAjax.ajax("confirmEntry",{
        "processInstanceId": $CertusJsonAjax.getProInstanceId(),
        "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
    },function(res){
        if(res.data == "success"){
            findBacklogPerson($CertusFormAjax,$CertusJsonAjax.getStepInstanceId());
            history.back();
            return;
        }
        layer.msg("程序出错");
    })
}

